const Koa = require('koa');
const mysql = require('./bootstrap/mysql');

// 注意require('koa-router')返回的是函数:
const bodyParser = require('koa-bodyparser');
const router = require('./bootstrap/router');

const app = new Koa();

// body解释器
app.use(bodyParser());

// log request URL:
app.use(async (ctx, next) => {
    console.log(`Process ${ctx.request.method} ${ctx.request.url}...`);
    await next();
});

// // 初始化路由
router(app);

app.listen(3000);
console.log('app started at port 3000...');